//#define __DEBUG__
// by Xeno
#define THIS_FILE "x_m145.sqf"
#include "x_setup.sqf"
private ["_ogroup", "_poss", "_leadero"];

_mpos = markerPos QGVAR(sm_145);
_mpos set [2,0];
GVAR(x_sm_pos) = [_mpos]; // index: 42,   Officer in forrest near Air Station Mike-26
GVAR(x_sm_type) = "normal"; // "convoy"

#ifdef __SMMISSIONS_MARKER__
if (true) exitWith {};
#endif

if (X_Client && {!GVAR(IS_HC_CLIENT)}) then {
#ifndef __TT__
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_1451");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_1452");
#else
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_1453");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_1454");
#endif
};

if (call FUNC(checkSHC)) then {
	__PossAndOther
	__GetEGrp(_ogroup)
	_sm_vehicle = _ogroup createUnit [GVAR(soldier_officer), _poss, [], 0, "FORM"];
	if (GVAR(without_nvg) == 0) then {
		_sm_vehicle call FUNC(removeNVGoggles);
	};
	_sm_vehicle setVariable ["BIS_noCoreConversations", true];
	if (GVAR(domdatabase)) then {
		_sm_vehicle addEventHandler ["killed", {if (isPlayer (_this select 1)) then {[QGVAR(PAIKP), _this select 1] call FUNC(NetCallEventCTS)}}];
	};
#ifndef __TT__
	_sm_vehicle addEventHandler ["killed", {_this call FUNC(KilledSMTarget500)}];
	removeAllWeapons _sm_vehicle;
#else
	_sm_vehicle addEventHandler ["killed", {_this call FUNC(KilledSMTargetNormal)}];
#endif
	sleep 2.123;
	["specops", 3, "basic", 3, _poss, 100,true] spawn FUNC(CreateInf);
	sleep 2.123;
	_leadero = leader _ogroup;
	_leadero setRank "COLONEL";
	_ogroup setbehaviour "AWARE";
	_leadero disableAI "MOVE";
#ifndef __TT__
	[_sm_vehicle] spawn FUNC(sidearrest);
#endif
};
